﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using motelmanagement.common;
using System.Data;
using System.Data.OleDb;
namespace motelmanagement.dao
{
    class RoomPriceDAO
    {
        SqlUtil sqlUtil = new SqlUtil();
        OleDbCommand cmd = null;
        public DataTable getAllRoomPrice() {
            cmd = new OleDbCommand("Select * from Room_price");
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public DataTable getRoomPrice(int id)
        {
            cmd = new OleDbCommand("Select * from Room_price Where room_price_id=@id");
            cmd.Parameters.Add("id",SqlDbType.Int).Value = id;
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public void insertRoomPrice(string roomPriceName)
        {
            cmd = new OleDbCommand("Insert Into Room_price(room_price_name) Values(@name)");
            cmd.Parameters.Add("name", SqlDbType.NText).Value = roomPriceName;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void updateRoomPrice(int roomPriceId,string roomPriceName)
        {
            cmd = new OleDbCommand("Update Room_price Set room_price_name = @name Where room_price_id=@id");
            cmd.Parameters.Add("name", SqlDbType.NText).Value = roomPriceName;
            cmd.Parameters.Add("id", SqlDbType.Int).Value = roomPriceId;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void deleteRoomPrice(int id)
        {
            cmd = new OleDbCommand("Delete From Room_price Where room_price_id=@id");
            cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
    }
}
